package com.ruoyi.web.controller.process;

import java.util.List;

import com.ruoyi.common.annotation.PropertyInject;
import com.ruoyi.common.enums.InjectType;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.process.domain.WorkTakeoffhat;
import com.ruoyi.process.service.IWorkTakeoffhatService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 脱帽管理Controller
 *
 * @author ruoyi
 * @date 2021-07-12
 */
@RestController
@RequestMapping("/process/takeoffhat")
public class WorkTakeoffhatController extends BaseController
{
    @Autowired
    private IWorkTakeoffhatService workTakeoffhatService;

    /**
     * 查询脱帽管理列表
     */
    @PreAuthorize("@ss.hasPermi('process:takeoffhat:list')")
    @GetMapping("/list")
    public TableDataInfo list(WorkTakeoffhat workTakeoffhat)
    {
        startPage();
        List<WorkTakeoffhat> list = workTakeoffhatService.selectWorkTakeoffhatList(workTakeoffhat);
        return getDataTable(list);
    }

    /**
     * 导出脱帽管理列表
     */
    @PreAuthorize("@ss.hasPermi('process:takeoffhat:export')")
    @Log(title = "脱帽管理", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(WorkTakeoffhat workTakeoffhat)
    {
        List<WorkTakeoffhat> list = workTakeoffhatService.selectWorkTakeoffhatList(workTakeoffhat);
        ExcelUtil<WorkTakeoffhat> util = new ExcelUtil<WorkTakeoffhat>(WorkTakeoffhat.class);
        return util.exportExcel(list, "脱帽管理数据");
    }

    /**
     * 获取脱帽管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('process:takeoffhat:query')")
    @GetMapping(value = "/{workTakeoffhatId}")
    public AjaxResult getInfo(@PathVariable("workTakeoffhatId") Long workTakeoffhatId)
    {
        return AjaxResult.success(workTakeoffhatService.selectWorkTakeoffhatById(workTakeoffhatId));
    }

    /**
     * 新增脱帽管理
     */
    @PreAuthorize("@ss.hasPermi('process:takeoffhat:add')")
    @Log(title = "脱帽管理", businessType = BusinessType.INSERT)
    @PostMapping
    @PropertyInject(type= InjectType.Insert)
    public AjaxResult add(@RequestBody WorkTakeoffhat workTakeoffhat)
    {
        return toAjax(workTakeoffhatService.insertWorkTakeoffhat(workTakeoffhat));
    }

    /**
     * 修改脱帽管理
     */
    @PreAuthorize("@ss.hasPermi('process:takeoffhat:edit')")
    @Log(title = "脱帽管理", businessType = BusinessType.UPDATE)
    @PutMapping
    @PropertyInject(type= InjectType.Update)
    public AjaxResult edit(@RequestBody WorkTakeoffhat workTakeoffhat)
    {
        return toAjax(workTakeoffhatService.updateWorkTakeoffhat(workTakeoffhat));
    }

    /**
     * 删除脱帽管理
     */
    @PreAuthorize("@ss.hasPermi('process:takeoffhat:remove')")
    @Log(title = "脱帽管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{workTakeoffhatIds}")
    public AjaxResult remove(@PathVariable Long[] workTakeoffhatIds)
    {
        return toAjax(workTakeoffhatService.deleteWorkTakeoffhatByIds(workTakeoffhatIds));
    }
}
